<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    // let str = 'qwer'
    // console.log( str.replace('q', 'p') )


    // let str = '我是{{name}}'
    // let res = str.replace('{{name}}', 'name')
    // console.log( res )

    let reg = /{{\s*([a-zA-Z]+)\s*}}/
    let str = '我是{{ name }}, 今年{{age}}'

    let arr = reg.exec(str) 
    let str2 = str.replace(arr[0], arr[1])

    let arr2 = reg.exec(str2)  
    let str3 = str2.replace(arr2[0], arr2[1])

    let arr3 = reg.exec(str3)  
    console.log(arr3)
    console.log(str3)
    // let res = str3.replace(arr3[0], arr3[1])
    // console.log( str3 )
  </script>
</body>
</html>